#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/loacl/bin:/usr/local/sbin:~/bin
export PATH
DD=`date +%Y-%m-%d\ %H:%M`
VIP=172.23.4.201
FindVIP=`ip addr | grep $VIP | wc -l`
Serhealth=`ps -ef|grep /usr/sbin/kamailio|grep -v grep| wc -l`
if [ "$FindVIP" -eq 1 -a "$Serhealth" -eq 0 ] ; then
        /etc/init.d/kamailio start
        echo "$DD: start kamailio by chk_alive.sh" >> /etc/keepalived/SendSmsMail.log
        sleep 10
elif [ "$FindVIP" -eq 0 -a "$Serhealth" -gt 1 ] ; then
        /etc/init.d/kamailio stop
        echo "$DD: stop kamailio by chk_alive.sh" >> /etc/keepalived/SendSmsMail.log
        sleep 10
else
        exit 0
fi

